package com.xywy.tangandroid.adapter;

import java.util.List;

import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xywy.tangandroid.R;
import com.xywy.tangandroid.activity.QuestionDetailAct;
import com.xywy.tangandroid.base.BasicAdapter;
import com.xywy.tangandroid.bean.DoctorReply;

public class ExperReplayAdapter extends BasicAdapter<DoctorReply> {
   private List<DoctorReply> list;
   private LayoutInflater inflater;
   public <T> ExperReplayAdapter(Context context, List<DoctorReply> list) {
		super(context, list);
		this.list=list;
		this.context=context;
		this.inflater = LayoutInflater.from(context);
	}
   
   @Override
	public View getView(int position, View convertView, ViewGroup parent) {
	   viewholder holder;
	   final int i=position;
	   if(convertView==null){
		   holder=new viewholder();
		   convertView = inflater.inflate(R.layout.item_expert_replay, null);
		   holder.title=(TextView) convertView.findViewById(R.id.title);
		   holder.content=(TextView) convertView.findViewById(R.id.content1);
		   convertView.setTag(holder);
	   }else{
		   holder=(viewholder) convertView.getTag();
	   }
	   String  title= list.get(position).getTitle();
	   String content=list.get(position).getReply();
	   holder.title.setText(title);
	   holder.content.setText(content);
	    convertView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				Intent intent=new Intent(context, QuestionDetailAct.class);
				intent.putExtra("document_id", list.get(i).getDocument_id());
				intent.putExtra("flag", -100);
				context.startActivity(intent);
			}
		});
		return convertView;
	}
   
   public  class viewholder{
	   TextView  title;
	   TextView  content;
   }
}
